/*
    Copyright (C) 2008,2009 INdT - Instituto Nokia de Tecnologia
    Copyright (C) 2009,2010 ProFUSION embedded systems
    Copyright (C) 2009,2010 Samsung Electronics

    This file is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This file is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

   group {

      name: "webkit/widget/checkbox";
      min: 12 12;

      images {
         image: "widget/check/img_check_bg_enabled.png" COMP;
         image: "widget/check/img_check_bg_disabled.png" COMP;
         image: "widget/check/img_check_on.png" COMP;
         image: "widget/check/img_check_off.png" COMP;
         image: "widget/check/img_check_off_focus.png" COMP;
         image: "widget/check/img_check_on_focus.png" COMP;
         image: "widget/check/img_check_off_hover.png" COMP;
         image: "widget/check/img_check_on_hover.png" COMP;
      }

      script {
          public isEnabled;
          public isPressed;
          public isChecked;
          public isFocused;
          public isHovered;

          public show() {
              if (get_int(isEnabled) == 1) {
                  set_state(PART:"check_button", "default", 0.0);
                  set_state(PART:"bg", "enabled", 0.0);
                  if (get_int(isChecked) == 1) {
                      set_state(PART:"check_button", "enabled_checked", 0.0);
                      if (get_int(isFocused) == 1)
                          set_state(PART:"check_button", "focus_checked", 0.0);
                      if (get_int(isHovered) == 1 && get_int(isFocused) == 0)
                          set_state(PART:"check_button", "hovered_checked", 0.0);
                  }
                  else {
                      if (get_int(isFocused) == 1)
                          set_state(PART:"check_button", "focused", 0.0);
                      if (get_int(isHovered) == 1 && get_int(isFocused) == 0)
                          set_state(PART:"check_button", "hovered", 0.0);
                  }
              }
              else {
                  set_state(PART:"check_button", "disabled", 0.0);
                  set_state(PART:"bg", "disabled", 0.0);
                  if (get_int(isChecked) == 1)
                      set_state(PART:"check_button", "disabled_checked", 0.0);
              }
          }
      }

      parts {
         part {
            name: "bg";
            type: IMAGE;
            description {
               state: "default" 0.0;
               min: 12 12;
               max: 12 12;
               image {
                  normal: "widget/check/img_check_bg_enabled.png";
               }
            }
            description {
               state: "enabled" 0.0;
               inherit: "default" 0.0;
            }
            description {
               state: "disabled" 0.0;
               inherit: "default" 0.0;
               image {
                  normal: "widget/check/img_check_bg_disabled.png";
               }
            }
         }
         part {
            name: "check_button";
            type: IMAGE;
            description {
               state: "default" 0.0;
               min: 12 12;
               max: 12 12;
               image {
                  normal: "widget/check/img_check_off.png";
               }
            }
            description {
               state: "enabled_checked" 0.0;
               inherit: "default" 0.0;
               image {
                  normal: "widget/check/img_check_on.png";
               }
            }
            description {
               state: "disabled_checked" 0.0;
               inherit: "enabled_checked" 0.0;
               color: 255 255 255 150;
            }
            description {
               state: "disabled" 0.0;
               inherit: "default" 0.0;
               color: 255 255 255 150;
            }
            description {
               state: "hovered_checked" 0.0;
               inherit: "default" 0.0;
               image {
                  normal: "widget/check/img_check_on_hover.png";
               }
            }
            description {
               state: "hovered" 0.0;
               inherit: "default" 0.0;
               image {
                  normal: "widget/check/img_check_off_hover.png";
               }
            }
            description {
               state: "focus_checked" 0.0;
               inherit: "default" 0.0;
               image {
                  normal: "widget/check/img_check_on_focus.png";
               }
            }
            description {
               state: "focused" 0.0;
               inherit: "default" 0.0;
               image {
                  normal: "widget/check/img_check_off_focus.png";
               }
            }
         }
      }
      programs {
         program {
            name: "enabled";
            signal: "enabled";
            script {
               set_int(isEnabled, 1);
               show();
            }
         }
         program {
            name: "pressed";
            signal: "pressed";
            script {
               set_int(isPressed, 1);
               show();
            }
         }
        program {
            name: "checked";
            signal: "checked";
            script {
               set_int(isChecked, 1);
               show();
            }
         }
         program {
            name: "focused";
            signal: "focused";
            script {
               set_int(isFocused, 1);
               show();
            }
         }
          program {
            name: "hovered";
            signal: "hovered";
            script {
               set_int(isHovered, 1);
               show();
            }
         }
        program {
            name: "reset";
            signal: "reset";
            script {
               set_int(isEnabled, 0);
               set_int(isPressed, 0);
               set_int(isChecked, 0);
               set_int(isFocused, 0);
               set_int(isHovered, 0);
               show();
            }
         }
      }
   }
